package com.atmc.controller;

import com.atmc.bean.Matchs;
import com.atmc.bean.User;
import com.atmc.service.MatchsService;
import com.atmc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.*;


@Controller
public class LoginController {
    @Autowired
    MatchsService matchsService;
    @Autowired
    UserService userService;
    @RequestMapping("/login/after/join")
    public String quest1(){
        return "join";
    }

    @RequestMapping("/join/after/login")
    public String quest3(){
        return "login";
    }

    @RequestMapping("/jonin/after/index")
    public String quest4(){
        return "index";
    }

    @RequestMapping("/toregister")
    public String register(@RequestParam("username") String username,@RequestParam("password") String password,@RequestParam("email") String email){
        System.err.println(username+password+email);
        if (username !=null&&password !=null){
            User user=new User(null,username,password,email);
            userService.insertOne(user);
            return "login";

        }
        return "join";
    }














//    @PostMapping ("/login/after/index")
//    public String tologin(@RequestParam("username")String username, Model model){
//
//        List<Matchs> list = matchsService.getAll();
//        model.addAttribute("msg",list);
//        return "index";
//    }
}
